# Contributor: Alex McGrath <amk@amk.ie>
# Maintainer: Alex McGrath <amk@amk.ie>
pkgname=babashka
pkgver=1.3.188
pkgrel=0
pkgdesc="Native, fast starting Clojure interpreter for scripting"
url="https://github.com/babashka/babashka"
license="GPL-3.0-or-later"
arch="x86_64" # openjdk-mandrel
makedepends="openjdk17-static-libs openjdk17 openjdk-mandrel leiningen"

_bbcore_hash="52a6037bd4b632bffffb04394fb4efd0cdab6b1e"
_bbcurl_hash="e936acd40544eb637b6041c7e89454b21eb7ee34"
_bbnrepl_hash="edd3d613bfb9bf3adabfd0bda5c3f5c6ee85ec20"
_depsclj_hash="3e5dcdfe7b32e0d358a6f48cd46120596e83f02f"
_depstar_hash="c419b8c82041855d55593c5b561fc7cea8234712"
_fs_hash="374c36a3f7316e7a445f47220719283947a97e14"
_pods_hash="6ad6045b94bc871c5107bfc75d39643b6c1bc8ba"
_process_hash="abe7ea36ebf1d666834f73d35530df946a7c31bd"
_sci_hash="ad79a6c476affd1f8208efbfdba57992a68c8056"

source="babashka-$pkgver.tar.gz::https://github.com/babashka/babashka/archive/v$pkgver.tar.gz
https://github.com/borkdude/sci/archive/$_sci_hash.tar.gz
https://github.com/babashka/babashka.curl/archive/$_bbcurl_hash.tar.gz
https://github.com/babashka/babashka.nrepl/archive/$_bbnrepl_hash.tar.gz
https://github.com/babashka/depstar/archive/$_depstar_hash.tar.gz
https://github.com/babashka/process/archive/$_process_hash.tar.gz
https://github.com/babashka/pods/archive/$_pods_hash.tar.gz
https://github.com/borkdude/deps.clj/archive/$_depsclj_hash.tar.gz
https://github.com/babashka/fs/archive/$_fs_hash.tar.gz
https://github.com/babashka/babashka.core/archive/$_bbcore_hash.tar.gz
"

options="!check" # fails due to a dep on version of go-sqlite3 that is broken on musl

prepare() {
	default_prepare

	mv -Tv "$srcdir/sci-$_sci_hash" "$builddir/sci"
	mv -Tv "$srcdir/babashka.curl-$_bbcurl_hash" "$builddir/babashka.curl"
	mv -Tv "$srcdir/babashka.nrepl-$_bbnrepl_hash" "$builddir/babashka.nrepl"
	mv -Tv "$srcdir/depstar-$_depstar_hash" "$builddir/depstar"
	mv -Tv "$srcdir/process-$_process_hash" "$builddir/process"
	mv -Tv "$srcdir/pods-$_pods_hash" "$builddir/pods"
	mv -Tv "$srcdir/deps.clj-$_depsclj_hash" "$builddir/deps.clj"
	mv -Tv "$srcdir/fs-$_fs_hash" "$builddir/fs"
	mv -Tv "$srcdir/babashka.core-$_bbcore_hash" "$builddir/babashka.core"
}

build() {
	export GRAALVM_HOME=/usr/lib/jvm/java-17-openjdk/
	script/uberjar
	script/compile
}

check() {
	script/test
}

package() {
	install -Dm755 "$builddir"/bb \
		"$pkgdir"/usr/bin/bb
}

sha512sums="
8b9b65c72289ad4cb1dce518807e826a3827232d235a4e8b3be2237c7fe74c95f6caeacb34a25525a4136275b80414aa1f1c9ec5a023aa998a63a0543e5421e3  babashka-1.3.188.tar.gz
30bc3a066cb2f62c5384ad75166edc0e6d15970765dc9fee0b10bb7b24d8e44608d151abb2dfd12db32b6589756e6d853b171c0470289edda56abb9a0669f906  ad79a6c476affd1f8208efbfdba57992a68c8056.tar.gz
94219410d4e7f750bb36486e5a5f5fda8bcd35333aadd325db5e299a9985272e17b334180cb2d0a7eb4c104db459d96bbd0f9c38fbc1592195c9658a7aacf390  e936acd40544eb637b6041c7e89454b21eb7ee34.tar.gz
f8eee32ef1192212c6e774d24c88fc5aa9151f1452f22e3386a513f400aa346029d84cecb74c9e2f78d6d8fd3b8864890ef9198fa36caf7e29a9168f978ce418  edd3d613bfb9bf3adabfd0bda5c3f5c6ee85ec20.tar.gz
b8cf5a3a518ef3ccd8c95bb9b3e6782123c9908501ceba74153c06b14f90ee3728fa3b0e2f66d8f4625f2e8ebe8d29efcfe3adcd85ecc8e067edb95b3359caa2  c419b8c82041855d55593c5b561fc7cea8234712.tar.gz
174074639cd4bc04f8ea682f241afacb2d0b257e918defa9e528fdfe58e3597578398402cde36b65b609d7eeb37f908f504125814b072ecc2df87f8f66404511  abe7ea36ebf1d666834f73d35530df946a7c31bd.tar.gz
3707693151a2fa032426448326e77a99493017af82bff902160483ce6d5bed13d51e5ea92750f1725f26f1b66ed9256260ebbcbbce30897370553252d540faca  6ad6045b94bc871c5107bfc75d39643b6c1bc8ba.tar.gz
4a12791ee00b93dac45a7e9373e44398da17ba24577926f9c997a280be0027ba258912e6a8942042953a71bb8411a557bf03f6dd58909eb4706562d7598af88a  3e5dcdfe7b32e0d358a6f48cd46120596e83f02f.tar.gz
e96fb6c41b7366690d05818cbf1c6285c630639d6f7bebc25e735fd3cdec772221c2b37d39f14bfd7ba6d6f1be05b7cdf77d9c1a5f1ab007d4c9efc190ac801a  374c36a3f7316e7a445f47220719283947a97e14.tar.gz
2001b729aea5ca34b31e998920b77c935a15e796748fc4ee7943fd70ae8b1baa97885d56f7ab2cdb890cd4da4135112a3172c9a92ecfd1db047d0e6d5f738294  52a6037bd4b632bffffb04394fb4efd0cdab6b1e.tar.gz
"
